package com.gogowan.agroenterprise.widget.xlistview;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.gogowan.agroenterprise.R;

import java.util.ArrayList;
import java.util.List;


public class DialogListItemAdapter extends android.widget.BaseAdapter {

    protected Context mContext;
    protected LayoutInflater mInflater;
    protected List<WorkStateBean> items = new ArrayList<>();

    public DialogListItemAdapter(Context context) {
        this.mContext = context;
        this.mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }
    public void setList(List<WorkStateBean> datas){
        this.items.clear();
        if(datas != null){
            this.items.addAll(datas);
        }
    }
    @Override
    public int getCount() {
        return items.size();
    }

    @Override
    public WorkStateBean getItem(int position) {
        return items.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = this.mInflater.inflate(R.layout.dialog_list_view_item, null);
        TextView name_tv = (TextView) view.findViewById(R.id.name_tv);

        WorkStateBean info = getItem(position);
        if (info.isSelect()){
            name_tv.setTextColor(mContext.getResources().getColor(R.color.blue));
        }else{
            name_tv.setTextColor(mContext.getResources().getColor(R.color.font_black));

        }
        name_tv.setText(info.getName());

        return view;
    }

}